package com.itheima.deadlock;

public class Demo01 {

    public static void main(String[] args) {

        Object oA = new Object();
        Object oB = new Object();
        new Thread(() -> {
            while (true) {

                System.out.println("释放A锁");
            }
        }).start();
        new Thread(() -> {
            while (true) {
                huoquB();
                System.out.println("释放B锁");
            }
        }).start();

    }

    private synchronized static void huoquB() {
        System.out.println("获得到了B锁");
        huoquA();
        System.out.println("我要去北京");
        System.out.println("释放B锁");
    }

    private synchronized static void huoquA() {
        System.out.println("获得到了A锁");
        huoquB();
        System.out.println("释放A锁");

    }
}
